<?php

if(!$_cid && $_POST[_cid])
{
	mysql_connect("localhost", "canss", "1022") or die("Could not connect: ".mysql_error());
	$_cid=$_POST[_cid];
}
$_db = "contentsmetadata_db";

$queryb = "SELECT ContId FROM `$_db`.`tblLinkage`, `$_db`.`tblContentDescription` WHERE `$_db`.`tblLinkage`.tblCID_cid=`$_db`.`tblContentDescription`.tblCID_cid AND `$_db`.`tblLinkage`.tblPID_pid=`$_db`.`tblContentDescription`.tblPID_pid AND `$_db`.`tblLinkage`.tblCID_cid='$_cid';";
$resultb = mysql_query($queryb);
if($resultb)
{
	if($rowb=mysql_fetch_row($resultb))
		$_contid = $rowb[0];
}
if($_contid)
	$_method = "deleteUploadContInfo";

if($_method && $_contid)
{
	$_host = "webiptv.kaist.ac.kr";
	$_path = "/iptvportal/WebServices/GetContInfo.asmx";
	$_ns = "http://tempuri.org/";
	$_port = 80;
	$_param = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".
         "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n".
         " <soap12:Body>\n".
         "  <$_method xmlns=\"$_ns\">\n".
		 "   <contID>$_contid</contID>\n".
		 "  </$_method>".
         " </soap12:Body>\n".
         "</soap12:Envelope>\n";
	$_len = strlen($_param);

	$_fp = fsockopen($_host, $_port, $_errno, $_errstr, 30);
	if($_fp)
	{
		fputs($_fp, "POST $_path HTTP/1.1\n");
		fputs($_fp, "Host: $_host\n");
		fputs($_fp, "Content-Type: application/soap+xml; charset=utf-8\n");
		fputs($_fp, "Connection: Close\n");
		fputs($_fp, "Content-Length: ".$_len."\r\n\r\n");
		fputs($_fp, $_param);

		while(!feof($_fp))
			$_data = $_data.fgets($_fp, 4096);
		$_data = explode("\r\n\r\n", $_data);
	

		$_xml = new DOMDocument;
		$_xml->loadXML(stripslashes($_data[1]));
		$_lines = $_xml->getElementsByTagName('deleteUploadContInfoResult');
		foreach($_lines as $_line)
		{
			echo "SOAPCallback Result: ".$_line->nodeValue."<br/>";
			break;
		}
		fclose($_fp);
	}
}

?>
